package com.cashier.framework.web.service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import com.cashier.common.core.domain.entity.SysRole;
import com.cashier.common.core.domain.entity.SysUser;
import com.cashier.system.service.ISysMenuService;
import com.cashier.system.service.ISysRoleService;

/**
 * 用户权限处理
 * 
 * @author supermarket
 */
@Component
public class SysPermissionService
{
    @Autowired
    private ISysRoleService roleService;

    @Autowired
    private ISysMenuService menuService;

    /**
     * 获取角色数据权限
     * 
     * @return 角色权限信息
     */
    public Set<String> getRolePermission()
    {
        // 管理员拥有所有权限
//        if (user.isAdmin())
//        {
//            roles.add("admin");
//        }
//        else
//        {
        //        }
        return new HashSet<String>(roleService.selectRolePermissionByUserId());
    }

    /**
     * 获取菜单数据权限
     * 
     * @return 菜单权限信息
     */
    public Set<String> getMenuPermission()
    {
        Set<String> perms = new HashSet<String>();
        Set<String> rolePerms = menuService.selectMenuPermsByRoleId();
        perms.addAll(rolePerms);
        return perms;
    }
}
